package org.wbd.pklib.db;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;
import java.util.HashSet;
import java.util.Set;
import java.util.Date;


/**
 * Klasa reprezentująca wypozyczenie,obiekt tej klasy jest obiektowym odzwierciedleniem
 * rekord w tabeli "loan"
 */			
@Entity
@Table(name = "loan")			
public class Loan implements java.io.Serializable{
	private Integer loanId;
	private Integer userId;
	private Integer itemId;
	private Date loanDate;
	private Date returnDate;
	private String opinion;
	
	public Loan() {
	}
	
	public Loan(Integer loanId, Integer userId, Integer itemId, Date loanDate,
			Date returnDate, String opinion) {
		this.loanId = loanId;
		this.userId = userId;
		this.itemId = itemId;
		this.loanDate = loanDate;
		this.returnDate = returnDate;
		this.opinion = opinion;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "loanId", unique = true, nullable = false)
	public Integer getLoanId() {
		return loanId;
	}
	
	public void setLoanId(Integer loanId) {
		this.loanId = loanId;
	}
	
	@Column(name = "userId", unique = false, nullable = false, length = 11)
	public Integer getUserId() {
		return userId;
	}

	
	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	
	@Column(name = "itemId", unique = false, nullable = false, length = 11)
	public Integer getItemId() {
		return itemId;
	}

	public void setItemId(Integer itemId) {
		this.itemId = itemId;
	}

	@Column(name = "loanDate", unique = false, nullable = false)
	public Date getLoanDate() {
		return loanDate;
	}

	
	public void setLoanDate(Date loanDate) {
		this.loanDate = loanDate;
	}

	@Column(name = "returnDate", unique = false, nullable = true)
	public Date getReturnDate() {
		return returnDate;
	}

	public void setReturnDate(Date returnDate) {
		this.returnDate = returnDate;
	}

	@Column(name = "opinion", unique = false, nullable = true)
	public String getOpinion() {
		return opinion;
	}

	public void setOpinion(String opinion) {
		this.opinion = opinion;
	}

	@Override
	public String toString() {
		return "Loan [loanId=" + loanId + ", userId=" + userId + ", itemId="
				+ itemId + ", loanDate=" + loanDate + ", returnDate="
				+ returnDate + ", opinion=" + opinion + "]";
	}
	
	
	
	
}
